<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>垂直居中的实现</title>
    <style>
        body {
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            gap: 10px;
        }

        #container {
            width: 150px;
            padding: 10px;
            contain: layout;
            border: 1px solid red;
        }
        p {
            border: 1px solid #333;
            margin: 5px;
            font-size: 14px;
        }

        .g-test {
            width: 150px;
            height: 150px;
            border: 1px solid green;
        }
    </style>
</head>
<body>
<div id="container">
    <p>Coco</p>
    ...
</div>
<div class="g-test"></div>
<script>
    let container = document.getElementById('container');

    container.addEventListener('click',() =>{
        let p_c=  document.createElement('p');
        p_c.innerText = 'Coco';
        container.appendChild(p_c);
    })
</script>
</body>
</html>
